package com.alex.xmlyfm.entities.discoverrecommend;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by
 * Author: alex
 * Email:
 * Date: 15-10-21.
 */
public class DiscoverRecommendSpecial extends DiscoverRecommendItem{

    private List<SpecialItem> specialItems;

    public List<SpecialItem> getSpecialItems() {
        return specialItems;
    }

    @Override
    public void parseJSON(JSONObject json) throws JSONException {
        super.parseJSON(json);
        if (json != null){

            JSONArray list = json.getJSONArray("list");

            int len = list.length();
            if (len > 0 ){
                // TODO 解析list
                specialItems = new LinkedList<>();
                for (int i = 0; i < len; i++) {
                    JSONObject jsonObject = list.getJSONObject(i);

                    SpecialItem item = new SpecialItem();
                    item.parseJSON(jsonObject);
                    specialItems.add(item);
                }

            }

        }
    }
}

